From: Jasper St. Pierre Date: Sun, 4 Nov 2012 15:50:11 +0000 (-0500) Subject: popupMenu: Add smooth scrolling support for sliders X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~5184 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7d4e14f38455977ffb103acd85239ed6b1a9d816;p=gnome-shell.git popupMenu: Add smooth scrolling support for sliders Allowing smooth scrolling on the Y axis to accurately adjust the value of the slider. https://bugzilla.gnome.org/show_bug.cgi?id=687573 --- diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 239edaf1a..fd4b9280c 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -638,14 +638,23 @@ const PopupSliderMenuItem = new Lang.Class({ _onScrollEvent: function (actor, event) { let direction = event.get_scroll_direction(); + let delta; + + if (event.is_pointer_emulated()) + return; if (direction == Clutter.ScrollDirection.DOWN) { - this._value = Math.max(0, this._value - SLIDER_SCROLL_STEP); - } - else if (direction == Clutter.ScrollDirection.UP) { - this._value = Math.min(1, this._value + SLIDER_SCROLL_STEP); + delta = -SLIDER_SCROLL_STEP; + } else if (direction == Clutter.ScrollDirection.UP) { + delta = +SLIDER_SCROLL_STEP; + } else if (direction == Clutter.ScrollDirection.SMOOTH) { + let [dx, dy] = event.get_scroll_delta(); + // Even though the slider is horizontal, use dy to match + // the UP/DOWN above. + delta = -dy / 10; } + this._value = Math.min(Math.max(0, this._value + delta), 1); this._slider.queue_repaint(); this.emit('value-changed', this._value); },